package com.mycontract.suitepro.components.keyboard

import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.RelativeLayout
import androidx.fragment.app.FragmentManager
import com.mycontract.suitepro.R
import com.mycontract.suitepro.base.BaseFormAction
import com.mycontract.suitepro.databinding.ViewContractSuiteNumberKeyboardBinding

class NumberKeyboard : RelativeLayout, BaseFormAction {

    lateinit var mContractSuiteViewContractSuiteBinding: ViewContractSuiteNumberKeyboardBinding
    private lateinit var vContractSuiteRootContractSuiteView: View

    private var mContractSuiteSupportContractSuiteFragmentContractSuiteManager: FragmentManager? = null

    private var mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener: (Int) -> Unit = {}

    constructor(context: Context?) : this(context, null)
    constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : this(
        context,
        attrs,
        defStyleAttr,
        0
    )

    @SuppressLint("Recycle")
    constructor(
        context: Context?,
        attrs: AttributeSet?,
        defStyleAttr: Int,
        defStyleRes: Int,
    ) : super(
        context,
        attrs,
        defStyleAttr,
        defStyleRes
    ) {
        context?.let {
            vContractSuiteRootContractSuiteView = View.inflate(it, R.layout.view_contract_suite_number_keyboard, this)
            mContractSuiteViewContractSuiteBinding = ViewContractSuiteNumberKeyboardBinding.bind(vContractSuiteRootContractSuiteView)
            initContractSuiteSubviews()
        }
    }

    override fun initContractSuiteSubviews() {
        try {
            mContractSuiteViewContractSuiteBinding.textKeyboardNum0.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(0)
            }

            mContractSuiteViewContractSuiteBinding.textKeyboardNum1.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(1)
            }

            mContractSuiteViewContractSuiteBinding.textKeyboardNum2.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(2)
            }

            mContractSuiteViewContractSuiteBinding.textKeyboardNum3.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(3)
            }

            mContractSuiteViewContractSuiteBinding.textKeyboardNum4.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(4)
            }

            mContractSuiteViewContractSuiteBinding.textKeyboardNum5.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(5)
            }

            mContractSuiteViewContractSuiteBinding.textKeyboardNum6.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(6)
            }

            mContractSuiteViewContractSuiteBinding.textKeyboardNum7.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(7)
            }

            mContractSuiteViewContractSuiteBinding.textKeyboardNum8.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(8)
            }

            mContractSuiteViewContractSuiteBinding.textKeyboardNum9.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(9)
            }

            mContractSuiteViewContractSuiteBinding.imageKeyboardDel.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(-1)
            }

            mContractSuiteViewContractSuiteBinding.imageKeyboardDismiss.setOnClickListener {
                mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener.invoke(-2)
            }
        } catch (e: java.lang.Exception) {
            e.printStackTrace()
        }
    }

    override fun setContractSuiteFragmentContractSuiteManager(manager: FragmentManager) {
        mContractSuiteSupportContractSuiteFragmentContractSuiteManager = manager
    }

    override fun setContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener(listener: (Int) -> Unit) {
        mContractSuiteOnContractSuiteActionContractSuiteClickContractSuiteListener = listener
    }

    override fun setContractSuiteTitle(title: String) {

    }

    override fun setContractSuiteDetail(detail: String) {

    }

    override fun setContractSuiteContent(content: String) {

    }

    override fun setContractSuiteHint(hint: String) {

    }

    override fun setContractSuiteDetailContractSuiteColor(detailColor: Int) {

    }

    override fun setContractSuiteTitleContractSuiteColor(titleColor: Int) {

    }
}